package com.ojoin.trade.supplyloan_core.web.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.exception.DaoException;
import com.ojoin.trade.common.web.dao.impl.BaseDaoImpl;
import com.ojoin.trade.supplyloan_core.web.dao.TbSlSupplyloginCheckDao;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlSupplyloginCheck;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 15-10-22
 * Time: 下午1:18
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class TbSlSupplyloginCheckDaoImpl extends BaseDaoImpl<TbSlSupplyloginCheck> implements TbSlSupplyloginCheckDao {
    
	
	 @Override
	 /**
    * 查询电商平台不可登陆账号
    * @param joinuserNo
    * @throws BusinessException
    */
	  
	
	public List<TbSlSupplyloginCheck> querySupplyChainPlatformUserCanNotLogin(int joinuserNo,String time)
			throws BusinessException { 
    	String mapMethodName="selectSupplyChainPlatformUserCanNotLogin";
        Map<String,Object> paramap=new HashMap<String, Object>();
        paramap.put("joinuserNo",joinuserNo);   
        paramap.put("checkDate",time);  
            
    	List<TbSlSupplyloginCheck> list = this.sqlSessionTemplate.selectList(getSqlName(mapMethodName),paramap);
            
		return list;
	} 
	 
	 
	 
	
	@Override
    public void insertTbSlloginCheck(TbSlSupplyloginCheck logincheckvo) throws BusinessException {

        String mapMethodName ="insert";
        try{
            this.sqlSessionTemplate.insert(getSqlName(mapMethodName),logincheckvo);
        }catch (Exception e) {
            throw new DaoException(String.format("插入商户日登陆情况信息表出错！joinid==="+logincheckvo.getIdOfTbMerchantUser()+"语句：%s",
                    getSqlName(mapMethodName)), e);
        }

    }

    @Override
    public TbSlSupplyloginCheck queryTbSlLogincheck(int joinid, String date) throws BusinessException {

        String mapMethodName="selectByJoinidanddate";
        HashMap<String,Object> paramap=new HashMap<String, Object>();
        paramap.put("id_of_tb_merchant_user",joinid);
        paramap.put("check_date",date);
        try {
            List list = this.sqlSessionTemplate.selectList(getSqlName(mapMethodName),
                    paramap);
            if (list != null && list.size() >0)
                return (TbSlSupplyloginCheck) list.get(0);
        } catch (Exception e) {
            throw new DaoException(String.format("根据商户的joinid查询商户日登陆情况信息表出错->" + joinid + "出错！语句：%s",
                    getSqlName(mapMethodName)), e);
        }
        return null;
    }
}
